package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.ViewEvento;

@SuppressWarnings("serial")
public class ViewEventoDataModel extends PrimeDataModel<ViewEvento> {

    public ViewEventoDataModel() {
    }

    public ViewEventoDataModel(Object data) {
        super(data);
    }
    
    @SuppressWarnings("unchecked")
	@Override
    public ViewEvento getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<ViewEvento> lista = (List<ViewEvento>) getWrappedData();
        
        for(ViewEvento viewEvento : lista) {
        	String id = ""+viewEvento.getIdEvento();
            if(id.equals(rowKey))
                return viewEvento;
        }
        
        return null;
    }

    @Override
    public String getRowKey(ViewEvento cidade) {
        return ""+cidade.getIdEvento();
    }
}
                    
